<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_ad_detail.v-'.AC_VERSION.'.css'))?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/custom_post_ad.v-'.AC_VERSION.'.css'))?>
<?php $this->placeholder('container-class')->set('post_ad preview')?>
<?php $this->headLink()->appendStylesheet(Ac_Util::getImageBaseUrl('/css/pretty-photo/prettyPhoto.v-'.AC_VERSION.'.css'))?>
<?php $this->JQuery()->addJavascriptFile(Ac_Util::getImageBaseUrl('/js/pretty-photo/jquery.prettyPhoto.v-'.AC_VERSION.'.js'))?>
<?php $this->JQuery()->javascriptCaptureStart()?>


    var prettyPhoto;
    $(document).ready(function(){
        prettyPhoto = $("#detail_content_pic_gallery a").prettyPhoto({default_width:800, default_height:500, animationSpeed:'slow', theme:"facebook", autoplay_slideshow: false});
    });



    $j("#detail_content_pic_gallery a").prettyPhoto({default_width:800, default_height:500, animationSpeed:'slow', theme:"facebook", autoplay_slideshow: false});

    $j('#thumblist a').unbind('click').click(function (event) {
        $j('#main_photo_link').trigger('click');
        event.stopImmediatePropagation();
        event.preventDefault();
        return false;
    });

    $j('#detail_content_pic_gallery .thumb').hover(function() {
        var big    = $j(this).parent().attr('href');
        var target = $j(this).parent().attr('rel2');
        var id     = $j(this).parent().attr('id');
        var par = $j(this).parent();


        if ($j("#main_photo").attr('src') == target) {
            return;
        }
        $j("#main_photo").fadeOut(100, function() {
            $j("#main_photo").parent().attr('href', big).attr('target', id);
            $j("#main_photo").attr('src', target);
            $j("#main_photo").attr('rel', id);
            $j('#thumblist a').attr('rel','prettyPhoto[pp_gal]');
            par.removeAttr('rel');
            $j("#main_photo").fadeIn(100);
        });
    });

    $j('#main_photo_link').click(function(event) {
        event.preventDefault();
    });
<?php $this->JQuery()->javascriptCaptureEnd()?>
<section class="intro"><h1><?php echo $this->t('Preview Your Ad')?></h1>
<p><?php echo $this->t('Your Ad has not been posted. (<a __1__>Close Preview</a>)', null, 'onclick="window.close();return false;" href="#"')?></p>
</section>
<section class="ad_detail">
    <p id="listing_search_action"> 
        <span id="listedin">
            <?php echo $this->t('Listed in Category:')?>
            <?php if (!empty($this->listing->category)): ?>
                <?php $tmp = $this->listing->category[0]->getParentTree();?>
                <?php foreach((array)$tmp as $k => $cat):?>
                    <?php if (empty($this->mode) || $this->mode != 'preview'):?>
                        <a href="<?php echo $cat->url()?>"><?php echo $cat->name?></a> &raquo;
                    <?php else:?>
                        <?php echo $cat->name?> &raquo;
                    <?php endif;?>
                <?php endforeach;?>
            <?php endif;?>
        </span>
    </p>
    <h1>
        <em><?php echo $this->listing->title?></em>
    </h1>
    <section class="grid_8 main_section" id="main_section">
        <section class="text grid_4">
            <section class="general">
                <dl>
                    <dt><?php echo $this->t('Posted By')?>:</dt>
                    <dd>
                        <!--<a href="#"><img src="<?php //echo $this->thumbnail()->scale($this->listing->user->image, 100, 100);?>"></a>-->
                    </dd>
                    <?php if(!empty($this->listing->user)):?>
                        <dd><?php echo $this->listing->user?><span> (</span><a href="<?php echo $this->listing->user->url()?>">View All Ads</a><span>)</span></dd>
                    <?php endif; ?>

                    <?php echo $this->price($this->listing);?>
                    <?php echo $this->dtDd($this->t('Location'), $this->listing->area_l2)?>
                    <?php echo $this->dtDd($this->t('Posted'), date(MEDIUM_DATE_FORMAT, $this->listing->posted_at))?>
                    <?php echo $this->dtDd($this->t('Number of Views'), $this->listing->number_views)?>
                </dl>
            </section>
            <?php $partial_name = $this->listing->getAdDetailPartialName();?>
            <?php if(!empty($partial_name)):?>
            <?php echo $this->Partial('index/'.$partial_name);?>
            <?php endif;?>
            <section class="description">
                <h2><?php echo $this->t('Description')?></h2>
                <p>
                    <?php
                        $text = $this->listing->description;
                        $text = preg_replace('#(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)#u', '<a href="$1" target="_blank">$1</a>', $text);
                        echo nl2br($text);
                    ?>
                </p>
                <?php if(!empty($this->listing->url)):?>
                    <p>
                        <a href="<?php echo $this->listing->url;?>"><?php echo $this->listing->url;?></a>
                    </p>
                <?php endif;?>
                <?php if(!empty($this->listing->user->about_us)):?>
                    <p>
                        <?php echo $this->listing->user->about_us;?>
                    </p>
                <?php endif;?>
            </section>
        </section>
        <section class="pic grid_4">
            <section class="gallery">
                <div id="detail_content_pic_gallery" class="gallery">
                    <div class="wraptocenter">
                        <span></span>
                        <?php if(!empty($this->listing->photos)):?>
                            <a href="<?php echo $this->thumbnail()->scale($this->listing->featured_photo);?>" id="main_photo_link" target="photo_0" rel="prettyPhoto[pp_gal]">
                                <img src="<?php echo $this->thumbnail()->scale($this->listing->featured_photo, 298, 298);?>" alt="<?php echo $this->t('__1__ - photo __2__', null, $this->listing->title, 1)?>" id="main_photo">
                            </a>
                        <?php else:?>
                            <img src="<?php echo $this->thumbnail()->scale('', 298, 298);?>" alt="<?php echo $this->t('__1__ - photo __2__', null, $this->listing->title, 1)?>" id="main_photo">
                        <?php endif;?>
                    </div>
                    <ul id="thumblist">
                        <?php foreach($this->listing->photos as $k => $photo) :?>
                            <li>
                                <?php
                                $rel = '';
                                if ($photo != $this->listing->featured_photo) {
                                    $rel = 'rel="prettyPhoto[pp_gal]" ';
                                }
                                ?>
                                <a href="<?php echo $this->thumbnail()->scale($photo)?>" <?php echo $rel;?> rel2="<?php echo $this->thumbnail()->scale($photo, 298, 298);?>" id="photo_<?php echo $k?>">
                                    <img src="<?php echo $this->thumbnail()->scale($photo, 43, 43);?>" class="thumb" alt="<?php echo $this->t('__1__ - photo __2__', null, $this->listing->title, $k)?>">
                                </a>
                            </li>
                        <?php endforeach;?>
                    </ul>
                </div>
            </section>
            <section class="google_street">
                <div id="streetview"></div>
            </section>
            <section class="google_map">
                <div id="map"></div>
            </section>
        </section>
    </section>
    <aside class="aside grid_4">
            <?php if(!empty($this->listing->user->cid)):?>
        <section class="contact">
            <h2><?php echo $this->t('Contact Information')?></h2>
            <dl>
                <?php $customs = array('Model_Listing_Residential','Model_Listing_Commercial','Model_Listing_Car','Model_Listing_Motorcycle','Model_Listing_Boat','Model_Listing_Regular');?>
                <?php if(empty($this->listing->user->cid)):
                      if(!empty($this->listing->user->un)):?>
                    <dt><?php echo $this->t('Contact Person')?></dt>
                    <dd><a href="<?php echo $this->listing->user->url()?>"><?php echo $this->listing->user->un?></a></dd>
                <?php endif; endif;?>
                <?php if(!empty($this->listing->user->cid)):?>
                    <?php //echo "<PRE>"; var_dump($this->listing->user);?>
                    <dt><?php echo $this->t('Company Name')?></dt>
                    <dd><a href="<?php echo $this->listing->user->url()?>"><?php echo $this->listing->user->company->name?></a></dd>
                <?php endif;?>
                <?php if(!empty($this->listing->user->cid)):?>
                    <dt><?php echo $this->t('Agent')?></dt>
                    <dd><?php echo $this->listing->user->fn.' '.$this->listing->user->ln?></dd>
                <?php endif;?>
                <?php if(!empty($this->listing->user->cid)):
                      if(!empty($this->listing->user->license_id)):?>
                    <dt><?php echo $this->t('Agent ID')?></dt>
                    <dd><?php echo $this->listing->user->license_id?></dd>
                <?php endif; endif;?>
                <?php if(!empty($this->listing->user->phone)):?>
                    <dt><?php echo $this->t('Contact No.')?></dt>
                    <dd><?php echo $this->listing->user->phone?></dd>
                <?php endif;?>
            </dl>
        </section>
    <?php endif; ?>
    </aside>
</section>
